package shun.demo.remote.display.client;


import android.os.Handler;
import android.os.Looper;
import android.os.Message;

import java.io.IOException;
import java.io.ObjectOutputStream;
import java.io.OutputStream;
import java.net.Socket;

/**
 * Created by chen on 14-5-9.
 */
public class SendHandler extends Handler {

    public static final int MESSAGE_SEND = 2;

    private ObjectOutputStream mObjectOutputStream;


    public SendHandler(Looper looper, ObjectOutputStream oos) {
        super(looper);
        mObjectOutputStream = oos;
    }

    @Override
    public void handleMessage(Message msg) {
        switch (msg.what) {

            case MESSAGE_SEND:
                try {
                    mObjectOutputStream.writeObject(msg.obj);
                } catch (IOException e) {
                    // TODO: report the connectivity is closed
                    e.printStackTrace();
                }
                break;
        }
    }

}
